import request from '../utils/request'
import qs from "qs";

export function connect(connection) {
    return request({
        url: 'connect',
        method: 'post',
        data: connection
    })
}

export function disConnect(connectionId) {
    let data = {
        connectionId: connectionId
    }
    return request({
        url: 'disConnect',
        method: 'post',
        data: data
    })
}

export function syncDisConnect(connectionId) {
    let data = qs.stringify({
        connectionId: connectionId
    })
    return fetch('http://localhost:8888/api/disConnect', {
        method: "post",
        body: data,
        headers: {'Content-Type': 'application/x-www-form-urlencoded'},
        keepalive: true
    })
}

export function getConnectInfo() {
    return request({
        url: 'getConnectInfo',
        method: 'get',
        params: {
        }
    })
}